library(ggplot2)
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v tibble 3.1.3 v dplyr 1.0.7
## v tidyr 1.1.3 v stringr 1.4.0
## v readr 2.0.0 v forcats 0.5.1
## v purrr 0.3.4
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(ggspatial)
library(sf)
## Linking to GEOS 3.9.0, GDAL 3.2.1, PROJ 7.2.1
library(ggthemes)
parks <- st_read("parks.kml")
## Reading layer `Layer #0' from data source
## `C:\Users\Alec\Desktop\Documents\Harvard\R\SpatialAnalysis\parks.kml'
## using driver `KML'
## Simple feature collection with 12491 features and 2 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -74.25537 ymin: 40.49613 xmax: -73.70182 ymax: 40.91138
## Geodetic CRS: WGS 84
schools <- st_read("schools.kml")
## Reading layer `schools' from data source
## `C:\Users\Alec\Desktop\Documents\Harvard\R\SpatialAnalysis\schools.kml'
## using driver `KML'
## Simple feature collection with 1709 features and 2 fields
## Geometry type: POINT
## Dimension: XY
## Bounding box: xmin: -74.24402 ymin: 40.50808 xmax: -73.63364 ymax: 40.9443
## Geodetic CRS: WGS 84
ggplot() +
annotation_map_tile(zoomin = 0, progress = "none", type = "hotstyle") +
geom_sf(data = parks, color = NA,
aes(fill = "Public Space")) +
geom_sf(data = schools, size = 1, shape = 20, alpha = 0.25, aes(color = "Schools")) +
labs(caption = "School Access to Public Space in NYC") +
scale_fill_manual(values = "forestgreen", name = "") +
scale_color_manual(values = c("red"), name = "")

ggplot() +
annotation_map_tile(zoomin = 0, progress = "none", type = "stamenwatercolor") +
geom_sf(data = parks, color = "#dc7dfd", alpha = 0.85) +
geom_sf(data = schools, color = "#fbfd7d", size = 1, shape = 11, alpha = 0.8) +
labs(caption = "A Bad Map That Resembles Bubblegum")
